package com.entmanage.base.hrm.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.entmanage.common.annotation.Log;
import com.entmanage.common.core.controller.BaseController;
import com.entmanage.common.core.domain.AjaxResult;
import com.entmanage.common.enums.BusinessType;
import com.entmanage.base.hrm.domain.HrmEmployeeExperience;
import com.entmanage.base.hrm.service.IHrmEmployeeExperienceService;
import com.entmanage.common.utils.poi.ExcelUtil;
import com.entmanage.common.core.page.TableDataInfo;

/**
 * 员工工作经历子Controller
 *
 * @author lsq
 * @date 2025-09-02
 */
@Api(tags = {"hrm-HrmEmployeeExperience模块"}, description = "员工工作经历子")
@RestController
@RequestMapping("/hrm/experience")
public class HrmEmployeeExperienceController extends BaseController
{
    @Autowired
    private IHrmEmployeeExperienceService hrmEmployeeExperienceService;

    /**
     * 查询员工工作经历子列表
     */
    @PreAuthorize("@ss.hasPermi('hrm:experience:list')")
    @GetMapping("/list")
    public TableDataInfo list(HrmEmployeeExperience hrmEmployeeExperience)
    {
        startPage();
        List<HrmEmployeeExperience> list = hrmEmployeeExperienceService.selectHrmEmployeeExperienceList(hrmEmployeeExperience);
        return getDataTable(list);
    }

    /**
     * 导出员工工作经历子列表
     */
    @PreAuthorize("@ss.hasPermi('hrm:experience:export')")
    @Log(title = "员工工作经历子", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HrmEmployeeExperience hrmEmployeeExperience)
    {
        List<HrmEmployeeExperience> list = hrmEmployeeExperienceService.selectHrmEmployeeExperienceList(hrmEmployeeExperience);
        ExcelUtil<HrmEmployeeExperience> util = new ExcelUtil<HrmEmployeeExperience>(HrmEmployeeExperience.class);
        util.exportExcel(response, list, "员工工作经历子数据");
    }

    /**
     * 获取员工工作经历子详细信息
     */
    @PreAuthorize("@ss.hasPermi('hrm:experience:query')")
    @GetMapping(value = "/{expId}")
    public AjaxResult getInfo(@PathVariable("expId") Long expId)
    {
        return success(hrmEmployeeExperienceService.selectHrmEmployeeExperienceByExpId(expId));
    }

    /**
     * 新增员工工作经历子
     */
    @PreAuthorize("@ss.hasPermi('hrm:experience:add')")
    @Log(title = "员工工作经历子", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HrmEmployeeExperience hrmEmployeeExperience)
    {
        return toAjax(hrmEmployeeExperienceService.insertHrmEmployeeExperience(hrmEmployeeExperience));
    }

    /**
     * 修改员工工作经历子
     */
    @PreAuthorize("@ss.hasPermi('hrm:experience:edit')")
    @Log(title = "员工工作经历子", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HrmEmployeeExperience hrmEmployeeExperience)
    {
        return toAjax(hrmEmployeeExperienceService.updateHrmEmployeeExperience(hrmEmployeeExperience));
    }

    /**
     * 删除员工工作经历子
     */
    @PreAuthorize("@ss.hasPermi('hrm:experience:remove')")
    @Log(title = "员工工作经历子", businessType = BusinessType.DELETE)
    @DeleteMapping("/{expIds}")
    public AjaxResult remove(@PathVariable Long[] expIds)
    {
        return toAjax(hrmEmployeeExperienceService.deleteHrmEmployeeExperienceByExpIds(expIds));
    }

    /**
     * 根据员工ID查询工作经历列表
     */
    @GetMapping("/listByEmpId/{empId}")
    public AjaxResult listByEmpId(@PathVariable Long empId) {
        List<HrmEmployeeExperience> list = hrmEmployeeExperienceService.selectExperienceByEmpId(empId);
        return AjaxResult.success(list);
    }
}
